//
//  AppInnerNotificationManager.swift
//  XiaoweHealthy
//
//  Created by Riven on 2022/8/30.
//

import Foundation


class AppInnerNotificationManager {
    
    class func addNotification(name: Notification.Name, observer: Any, selector: Selector, object: Any?) {
        log.info("新增通知 name = \(name) \n")
        
        NotificationCenter.default.addObserver(observer, selector: selector, name: name, object: object)
    }
    
    class func postNotification(name: Notification.Name, object: Any?) {
        log.info("发送通知 name = \(name) \n")
        
        NotificationCenter.default.post(name: name, object: object)
    }
    
}

extension AppInnerNotificationManager {
    
    /// 登录通知
    static let kAccountLoginNotificationName = Notification.Name("AccountLoginNotificationName")
    
    class func addAccountLoginNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kAccountLoginNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postAccountLoginNotification(isLogined: Bool) {
        postNotification(name: kAccountLoginNotificationName, object: isLogined)
    }
    
}

extension AppInnerNotificationManager {
    
    /// 刷新用户列表通知
    static let kRefreshUserListNotificationName = Notification.Name("RefreshUserListNotificationName")
    
    class func addRefreshUserListNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kRefreshUserListNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postRefreshUserListNotification(object: Any?) {
        postNotification(name: kRefreshUserListNotificationName, object: object)
    }
    
    /// 信息变更通知
    static let kInfoChangeNotificationName = Notification.Name("InfoChangeNotificationName")
    class func addInfoChangeNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kInfoChangeNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postInfoChangeNotification(object: Any?) {
        postNotification(name: kInfoChangeNotificationName, object: object)
    }
    
    /// 绑定成功通知
    static let kBindDeviceNotificationName = Notification.Name("BindDeviceNotificationName")
    class func addBindDeviceNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kBindDeviceNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postBindDeviceNotification(object: Any?) {
        postNotification(name: kBindDeviceNotificationName, object: object)
    }
    
    /// 上报绑定信息状态通知
    static let kReportBindDeviceStateNotificationName = Notification.Name("ReportBindDeviceStateNotificationName")
    class func addReportBindDeviceStateNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kReportBindDeviceStateNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postReportBindDeviceStateNotification(object: Any?) {
        postNotification(name: kReportBindDeviceStateNotificationName, object: object)
    }
    
    /// 刷新预约记录列表通知
    static let kRefreshBookedRecordListNotificationName = Notification.Name("RefreshBookedRecordListNotificationName")
    
    class func addRefreshBookedRecordListNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kRefreshBookedRecordListNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postRefreshBookedRecordListNotification(object: Any?) {
        postNotification(name: kRefreshBookedRecordListNotificationName, object: object)
    }
    
}

// MARK: - Fitting
extension AppInnerNotificationManager {
    
    /// 验配记录列表刷新通知
    static let kFittingRecordListRefreshNotificationName = Notification.Name("FittingRecordListRefreshNotificationName")
    
    class func addFittingRecordListRefreshNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kFittingRecordListRefreshNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postFittingRecordListRefreshNotification(object: Any?) {
        postNotification(name: kFittingRecordListRefreshNotificationName, object: object)
    }
    
    /// 专家验配
    static let kExpertFittingStatusNotificationName = Notification.Name("ExpertFittingStatusNotificationName")
    
    class func addExpertFittingStatusNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kExpertFittingStatusNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postExpertFittingStatusNotification(object: Any?) {
        postNotification(name: kExpertFittingStatusNotificationName, object: object)
    }
    
}

// MARK: - HearingTest
extension AppInnerNotificationManager {
    
    /// 测听结果
    static let kHandleHearingTestResultNotificationName = Notification.Name("HandleHearingTestResultNotificationName")
    
    class func addHandleHearingTestResultNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kHandleHearingTestResultNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postHandleHearingTestResultNotification(object: Any?) {
        postNotification(name: kHandleHearingTestResultNotificationName, object: object)
    }
    
}

// MARK: - Remote Fitting
extension AppInnerNotificationManager {
    
    /// 远程验配记录列表刷新通知
    static let kRemoteFittingRecordListRefreshNotificationName = Notification.Name("RemoteFittingRecordListRefreshNotificationName")
    
    class func addRemoteFittingRecordListRefreshNotification(_ observer: Any, selector: Selector) {
        addNotification(name: kRemoteFittingRecordListRefreshNotificationName, observer: observer, selector: selector, object: nil)
    }
    class func postRemoteFittingRecordListRefreshNotification(object: Any?) {
        postNotification(name: kRemoteFittingRecordListRefreshNotificationName, object: object)
    }
    
}
